package IOStreamTest.FileStream;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/*
文件字符输入流，只能读取普通文本
读取普通文本时，比较方便，快捷
 */
public class FileReaderTest1 {
    public static void main(String[] args){
        //创建字符输入流对象
        FileReader fr = null;
        try {
            fr = new FileReader("D:\\123.txt");
            //创建一个char数组，将读取到的数据存入char数组
            char[] chars = new char[4];
            int count = 0;
            while((count = fr.read(chars)) != -1){
                System.out.print(new String(chars,0,count));
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally{
            if(fr != null){
                try {
                    fr.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
